<?php
	header("Content-type: text/html; charset=UTF-8");

	$user=$suser=$pwd=$spwd='';
	
	$user = $_POST['user']; //jiehsou
	$pwd = $_POST['pwd'];

	//echo $user.$pwd;
	
	$con = mysql_connect("localhost","root","");//链接数据库
	if(!$con){
		die('连接失败');
	}
	
	mysql_select_db("weixin",$con);//选择那个数据库
	
	$result = mysql_query("select * from reg_tab"); //查询结果
	$num = mysql_num_rows($result);
	
	while($row = mysql_fetch_array($result)){
		$suser = $row['username'];
		$spwd = $row['pwd'];
		check($user,$suser,$pwd,$spwd);
	}
	function check($u,$su,$p,$sp){
		if($u==$su&&$p==$sp){
			ob_clean();
			echo json_encode(array('success'=>'ok'));
			exit;
		}
		else{
			ob_clean();
			echo json_encode(array('success'=>'no'));
		}
	}	
	mysql_close($con);
?>
